//package com.shwread.android.qysw.activity;
//
//import java.lang.reflect.Type;
//import java.util.List;
//
//import logic.bean.OrderFoodListBean;
//import logic.bean.OrderTakeoutTableBean;
//import logic.constants.Const;
//import logic.constants.DefaultConsts;
//import logic.dao.OrderTakeoutDao;
//import logic.util.ImageLoaderUtil;
//import logic.util.MoneyUtil;
//import logic.util.Utils;
//
//import org.apache.http.Header;
//
//import android.content.Intent;
//import android.os.Bundle;
//import android.os.Handler;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//import com.google.gson.reflect.TypeToken;
//import com.shwread.android.qysw10000133.R;
//import com.shwread.android.qysw.activity.BaseBusinessActivity;
//import com.shwread.android.ui.page.NewOrderIndexPage;
//import com.shwread.android.ui.widget.LoadingView;
//import com.shwread.http.ActionHelp;
//import com.shwread.http.base.Log;
//import com.shwread.http.base.ObjectHttpResponseHandler;
//
//
//public class OMFoodDetailActivity
//        extends
//        BaseBusinessActivity
//        implements
//        OnClickListener
//{
//
//	private ImageView         btnBack;
//	private LinearLayout      llBody, llPepperyGrade, llPepperyGradeDetail, llRecommendNum;
//	private LoadingView       loadingView;
//	private ImageView         ivImg, ivAdd;
//	private TextView          tvDetail, tvTitle, tvPrice;
//	private View              curMyView;
//	private long              foodId;
//	private long              sortId;
//	private OrderFoodListBean foodListBean;
//	private OrderTakeoutDao   orderDao;
//	private int               fromType;
//
//	@Override
//	protected void onCreate(Bundle savedInstanceState) {
//		super.onCreate(savedInstanceState);
//		foodId = getIntent().getExtras().getLong("foodId");
//		sortId = getIntent().getExtras().getLong("sortId");
//		curMyView = LayoutInflater.from(this).inflate(R.layout.om_food_detail_dialog, null);
//		fromType = getIntent().getIntExtra(DefaultConsts.FROM_TYPE, 0);
//		setContentView(curMyView);
//		findViews();
//		initLoadingView();
//		setListeners();
//		setFoodId(foodId);
//	}
//
//	@Override
//	protected void onResume() {
//		super.onResume();
//		orderDao = OrderTakeoutDao.getInstance(this);
//	}
//
//	public void setFoodId(long foodId) {
//		ActionHelp.qryFoodsDetail(this, foodId, new ObjectHttpResponseHandler<OrderFoodListBean>()
//		{
//			@Override
//			public Type getType() {
//				return new TypeToken<OrderFoodListBean>()
//				{
//				}.getType();
//			}
//
//			@Override
//			public void onFailure(int arg0, Header[] arg1, String arg2, Throwable arg3) {
//
//			}
//
//			@Override
//			public void onSuccess(int arg0, Header[] arg1, OrderFoodListBean arg2, String arg3) {
//				Log.i(arg3);
//				loadingView.setVisibility(View.GONE);
//				llBody.setVisibility(View.VISIBLE);
//				ivAdd.setEnabled(true);
//				foodListBean = arg2;
//				foodListBean.setSortId(sortId);
//				tvTitle.setText(arg2.getFoodName());
//				tvDetail.setText(arg2.getDetailDesc());
//				ImageLoaderUtil.loadWebUrl(arg2.getPicUrl(), ivImg, ImageLoaderUtil.getOptions(R.drawable.atlas_item_default_bg));
//				if (arg2.getHasActivity().equals("y"))
//				{
//					tvPrice.setText(Utils.getOneMoneyFormat(MoneyUtil.divide(arg2.getActivityPrice(), 100)) + "元");
//				}
//				else
//				{
//					tvPrice.setText(Utils.getOneMoneyFormat(MoneyUtil.divide(arg2.getPrice(), 100)) + "元");
//				}
//				if (arg2.getPeppery_grade() > 0)
//				{
//					llPepperyGrade.setVisibility(View.VISIBLE);
//					for (int i = 0; i < arg2.getPeppery_grade(); i++)
//                    {
//	                    ImageView image = new ImageView(OMFoodDetailActivity.this);
//	                    image.setImageResource(R.drawable.order_takeout_right_iv_ladu);
//	                    llPepperyGradeDetail.addView(image);
//                    }
//				}
//				int recommendStar = arg2.getRecommendNum();
//				for (int i = 0; i < recommendStar; i++)
//                {
//                    ImageView image = new ImageView(OMFoodDetailActivity.this);
//                    image.setImageResource(R.drawable.om_food_detail_star);
//                    llRecommendNum.addView(image);
//                }
//				if (NewOrderIndexPage.supplyTakeAway && NewOrderIndexPage.addressInfo != null && !NewOrderIndexPage.outRange && NewOrderIndexPage.addressAvailable && foodListBean.getPositions() != null && foodListBean.getPositions().size() > 0 && foodListBean.getPositions().contains(3) && foodListBean.getPositions().contains(4))
//				{//非外卖菜品不显示
//					ivAdd.setVisibility(View.VISIBLE);
//				}
//				else ivAdd.setVisibility(View.GONE);
//			}
//		});
//	}
//
//	private void findViews() {
//		ivImg = (ImageView) curMyView.findViewById(R.id.iv_om_food_detail_dialog);
//		ivAdd = (ImageView) curMyView.findViewById(R.id.om_food_detail_add);
//		ivAdd.setEnabled(false);
//		ivAdd.setVisibility(View.GONE);
//		tvDetail = (TextView) curMyView.findViewById(R.id.tv_om_food_detail_desc);
//		tvTitle = (TextView) curMyView.findViewById(R.id.tv_om_food_detail_name);
//		btnBack = (ImageView) curMyView.findViewById(R.id.common_header_back);
//
//		llBody = (LinearLayout) findViewById(R.id.ll_om_food_detail_body);
//		loadingView = (LoadingView) findViewById(R.id.order_loading_view);
//
//		tvPrice = (TextView) findViewById(R.id.tv_om_food_detail_price);
//
//		llPepperyGrade = (LinearLayout) findViewById(R.id.ll_om_food_detail_peppery_grade);
//		llPepperyGradeDetail = (LinearLayout) findViewById(R.id.ll_om_food_detail_peppery_grade_detail);
//		llPepperyGrade.setVisibility(View.GONE);
//
//		llRecommendNum = (LinearLayout) findViewById(R.id.ll_om_food_detail_recommend_num);
//	}
//
//	private void initLoadingView() {
//		loadingView.setLoadingAnim(R.anim.home_progress);
//		loadingView.changeLoadingStatus(0);
//		loadingView.setVisibility(View.VISIBLE);
//		llBody.setVisibility(View.GONE);
//	}
//
//	private void setListeners() {
//		btnBack.setOnClickListener(this);
//		ivAdd.setOnClickListener(this);
//	}
//
//	@Override
//	public void onClick(View v) {
//		switch (v.getId()) {
//			case R.id.common_header_back:
//				finish();
//				break;
//			case R.id.om_food_detail_add:
//				addFoodListBean();
//				Intent intent = new Intent();
//				if (fromType == 0)
//				{
//					intent.setClass(OMFoodDetailActivity.this, OrderTakeoutActivity.class);
//					startActivity(intent);
//				}
//				else if (fromType == 1)
//				{
//					intent.putExtra("foodBean", foodListBean);
//					setResult(RESULT_OK, intent);
//				}
//				finish();
//				break;
//		}
//	}
//
//	private void addFoodListBean() {
//		OrderTakeoutTableBean addBean = null;
//		List<OrderTakeoutTableBean> tableBeans = orderDao.getRightBeans();
//		if (tableBeans != null && tableBeans.size() > 0)
//		{
//			for (OrderTakeoutTableBean tableBean : tableBeans)
//			{
//				if ((tableBean.getAccount().equals(Const.phone_number) && tableBean.getSortId().equals(String.valueOf(foodListBean.getSortId())) && tableBean.getFoodId().equals(String.valueOf(foodListBean.getFoodId()))) || (tableBean.getAccount().equals(Const.phone_number) && foodListBean.getSortId() == 0 && tableBean.getFoodId().equals(String.valueOf(foodListBean.getFoodId()))))
//				{
//					addBean = tableBean;
//					int addCount = Integer.parseInt(addBean.getNum());
//					addBean.setNum((addCount + 1) + "");
//					foodListBean.setBuyNum(addCount + 1);
//				}
//			}
//		}
//		if (addBean == null)
//		{
//			addBean = new OrderTakeoutTableBean();
//			addBean.setAccount(Const.phone_number);
//			addBean.setSortId(String.valueOf(foodListBean.getSortId()));
//			addBean.setFoodId(String.valueOf(foodListBean.getFoodId()));
//			if (foodListBean.getHasActivity().equals("y")) addBean.setPrice(String.valueOf(foodListBean.getActivityPrice() / 100));
//			else addBean.setPrice(String.valueOf(foodListBean.getPrice() / 100));
//			addBean.setNum("1");
//			foodListBean.setBuyNum(1);
//		}
//		orderDao.addOrderTableBean(addBean);
//	}
//
//	@Override
//	public Handler getUIHandler() {
//		return null;
//	}
//
//}
